package com.vancouver.knows.business.service.impl;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.pangu.util.StringUtil;
import com.vancouver.knows.business.bean.HomeGridInfo;
import com.vancouver.knows.business.bean.HomeLiveFeedInfo;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

/**
 * Created by Administrator on 2016/6/16.
 */
public class LiveFeedHandler extends ACheckableJsonParser {

    public static final String HOMEPAGE_LIVE_FEED= "homepage_live_feed";
    private HashMap<String, Object> resultMap = new HashMap<String, Object>();
    @Override
    protected void parserContent(JSONObject content) throws Exception {
        //============跑马灯数据======================
        String liveFeed = content.getString("live_feed");
        if (StringUtil.isEmptyString(liveFeed)) {
            resultMap.put(HOMEPAGE_LIVE_FEED, new ArrayList<HomeGridInfo>());
        }else {
            List<HomeLiveFeedInfo> homeLiveFeedInfo = JSON.parseArray(liveFeed,
                    HomeLiveFeedInfo.class);
            resultMap.put(HOMEPAGE_LIVE_FEED, homeLiveFeedInfo);
        }

    }

    public HashMap<String, Object> getResultMap() {
        return resultMap;
    }
}
